import React, { Component } from 'react';
import { connect } from 'react-redux'
import { Modal, Form, Input, Radio, TreeSelect, Select, Row, Col, Button, Table } from 'antd';
const TreeNode = TreeSelect.TreeNode;
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const Option = Select.Option;

class ShowAssetModal extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    const { children, user, dispatch, item, ipParamIdList, viewList, } = this.props;
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 },
    };

    const getIpParam = data => data.map((item) => {
      return <Option key={item.id_ + ''}>{item.networkName}</Option>
    })

    const onAddDetail = () => {
      this.props.form.validateFields((err, values) => {
        if (!err) {
          dispatch({
            type: 'resourceGroup/queryAssetList',
            payload: values,
          })
        }
      });
    }
    const columns = [{
      title: '资产编号',
      dataIndex: 'assetNo',
      key: 'assetNo',
      fixed: 'left',
      width: 120
    }, {
      title: '资产分类',
      dataIndex: 'typeName',
      key: 'typeName',
      width: 120
    }, {
      title: '设备名称',
      dataIndex: 'assetName',
      key: 'assetName',
      width: 120
    }, {
      title: '品牌',
      dataIndex: 'brandName',
      key: 'brandName',
      width: 120,
    }, {
      title: '设备型号',
      dataIndex: 'modelName',
      key: 'modelName',
      width: 100,
    }, {
      title: '设备序列号',
      dataIndex: 'serialNo',
      key: 'serialNo',
      width: 120,
    }, {
      title: 'RFID编码',
      dataIndex: 'rfidNo',
      key: 'rfidNo',
      width: 100,
    }, {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      width: 60,
      render: (value, row, index) => {
        return (
          value == 1 ? "在库" : value == 2 ? "已上架" : value == 3 ? "已报废" : ''
        )
      }
    }, {
      title: '所在机房',
      dataIndex: 'roomName',
      key: 'roomName',
      width: 100,
    }, {
      title: '所在机柜',
      dataIndex: 'rackName',
      key: 'rackName',
      width: 100,
    }, {
      title: '起始U位',
      dataIndex: 'startU',
      key: 'startU',
      width: 70,
    }, {
      title: '购置时间',
      dataIndex: 'buyTime',
      key: 'buyTime',
      width: 150,
    }, {
      title: '维保结束日期',
      dataIndex: 'expirationTime',
      key: 'expirationTime',
      width: 150,
    }
    ];
    return (
      <span>
        <Modal
          maskClosable={this.props.maskClosable}
          confirmLoading={this.props.confirmLoading}
          title={this.props.title}
          visible={this.props.visible}
          width={1000}
          footer={[
            <Button key="close" type="primary" size="large" onClick={this.props.onCancel}>关闭</Button>
          ]}
          onCancel={this.props.onCancel}
          key={this.props.newKey}
        >
          <div style={{ backgroundColor: '#fff' }}>
            <div style={{}}>
              <div style={{ width: '100%', backgroundColor: '#fff', paddingLeft: '20px' }}>
                <Form layout={'inline'} style={{ marginTop: '-16px' }}>
                  <div style={{}}>
                    <div style={{ width: '100%', padding: "10px 20px 20px 0px" }}>
                      <Table columns={columns}
                        rowKey={record => record.id_}
                        dataSource={viewList}
                        pagination={false}
                        scroll={{ x: 1600 }}
                      />
                    </div>
                  </div>
                </Form>
              </div>
            </div>
          </div>
        </Modal>
      </span>
    );
  }

}

export default Form.create()(ShowAssetModal)
